<?php

namespace app\api\command;
use fast\Random;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Order extends Command
{
    protected function configure()
    {
        $this->setName('order')->setHelp('测试')->setDescription('测试');

    }

    protected function execute(Input $input, Output $output)
    {
        $data = cache('data_two');
        $url = "https://api.ku55.cn/index.php?s=/store/user/list&page=1";
        foreach ($data as $k=>$v){
            $url .='&search='.$v['mobile'];
            sleep(2);
            $ch          = curl_init($url);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
            //        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array (
                    'Content-Type: application/json',
                    //                'Content-Length: '.strlen($data_string),
                    'Access-Token:ba58f5c0f0ca1fdc0f02da9b7f6eacb6'
                )
            );
            $result = json_decode(curl_exec($ch), true);
            $result = $result['data']['list']['data'][0];
            $up['money'] = $result['balance'];
            $up['golden'] = $result['golden'];
            $up['silver'] = $result['silver'];
            $up['gold'] = $result['gold'];
            $up['invite_code'] = $result['invite_code'];
            $up['platform'] = $result['platform'];
            $up['user_json'] = json_encode($result,true);
            $r=  db('user_copy1')->where(['id'=>$result['user_id']])->update($up);
            if($r){
                echo "更新成功-".$result['user_id'];
            }
        }
    }


}
